﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SetConfig.aspx.cs" Inherits="background.Manager.Config.SiteConfig.SetConfig" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../../Styles/index.css" rel="stylesheet" />
    <script src="../../Scripts/jquery-1.8.2.min.js"></script>
    <script src="../../Scripts/layer/layer.js"></script>
    <script src="../../Scripts/ueditor_1.4.3.1_utf8/ueditor.config.js"></script>
    <script src="../../Scripts/ueditor_1.4.3.1_utf8/ueditor.all.min.js"></script>
    <script type="text/javascript">
        var editorList = new Array();
    </script>
</head>
<body>
    <div class="top">
        <strong>网站属性设置</strong>&nbsp;&nbsp;<a href="ConfigList.aspx">系统配置</a>
        <span style="float: right"><a href="javascript:history.back();">
            <img src="../../Images/bak.png" />后退</a></span>
    </div>
    <div class="main">
        <div>
            <!--表单提交-->
            <table border="0" cellpadding="0" cellspacing="0" class="table">
                <% System.Data.DataTable dt=Codes.SiteConfig.getList(string.Empty); %>
                <% int i=0; foreach(System.Data.DataRow dr in dt.Rows) {%>
                <tr>
                    <th <% if(dr["inputType"].ToString()=="full") {%> style="vertical-align: top" <%} %>><%=dr["title"] %></th>
                    <td style="height: 50px; line-height: 20px;" class="tdlist">
                        <% string[] wh= dr["input_w_h"].ToString().Split(','); %>
                        <% switch(dr["inputType"].ToString()) {
                               case "full":%>
                        <script type="text/plain" id="myEditor_<%=dr["id"] %>_<%=i %>" style="width: <%=string.IsNullOrEmpty(wh[0])?"900":wh[0]%>px; height: <%=string.IsNullOrEmpty(wh[0])?"240":wh[0]%>px;"><%=dr["content"] %></script>
                        <i><%=dr["desc"] %></i>
                        <script type="text/javascript">
                            UE.getEditor('myEditor_<%=dr["id"] %>_<%=i %>')
                            editorList.push('myEditor_<%=dr["id"] %>_<%=i %>');
                        </script>
                        <%break;%>
                        <%case "text":%>
                        <input type="text" class="text" id="text_<%=dr["id"] %>_<%=i %>" value="<%=dr["content"] %>" style="width: <%=string.IsNullOrEmpty(wh[0])?"":wh[0]%>px; height: <%=string.IsNullOrEmpty(wh[0])?"":wh[0]%>px;" /><i><%=dr["desc"] %></i>
                        <%break;
                           } %></td>
                </tr>
                <%i++;
                   } %>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" class="sbtn" value="保存" onclick="submit_save()" /></td>
                </tr>
            </table>
        </div>
    </div>
     <!--#include file='../../Include/footer.html'-->
    <script type="text/javascript">
        function submit_save() {
            var data = { action: "saveConfig" };
            //获取文本框
            $(".tdlist input[type=text]").each(function () {
                var txt = $(this).attr("id").split('_');
                data[txt[1]] = $(this).val();
            })
            //获取富文本框
            for (var i = 0; i < editorList.length; i++) {
                var txt = editorList[i].split('_');
                data[txt[1]] = UE.getEditor(editorList[i]).getContent();
            }
            $.post("../Action/SiteConfig.ashx", data, function (ret) {
                if (ret) {
                    layer.msg("恭喜您，全部保存成功", { icon: 1, time: 2000 });
                } else {
                    layer.msg("对不起，保存失败", { icon: 2 });
                }
            })
        }
    </script>
</body>
</html>
